import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:provide/provide.dart';
import 'package:study_flutter/yzhg/project/shop/provide/GoodsDetailProvide.dart';

class DetailCommentBar extends StatefulWidget {
  @override
  _DetailCommentBarState createState() => _DetailCommentBarState();
}

class _DetailCommentBarState extends State<DetailCommentBar> {


  @override
  Widget build(BuildContext context) {
    return Provide<GoodsDetailProvide>(builder: (context, child, childData){
      return Row(
        children: <Widget>[
          _leftDetailWidget(childData.detailCommentStatus),
          _rightCommentWidget(childData.detailCommentStatus)
        ],
      );
    });
  }

  /*详情按钮*/
  Widget _leftDetailWidget(bool status) {
    return InkWell(
      onTap: () {
        setState(() {
          Provide.value<GoodsDetailProvide>(context).cutDetailComment(true);
        });
      },
      child: Container(
        padding: EdgeInsets.all(10.0),
        alignment: Alignment.center,
        width: ScreenUtil().setWidth(375),
        decoration: BoxDecoration(
            color: Colors.white,
            border: Border(
                bottom: BorderSide(
                    width: 1.0, color: status ? Colors.pink : Colors.white))),
        child: Text(
          "详情",
          style: TextStyle(
              fontSize: ScreenUtil().setSp(28.0),
              color: status ? Colors.pink : Colors.black),
        ),
      ),
    );
  }

  /*评论按钮*/
  Widget _rightCommentWidget(bool status) {
    return InkWell(
      onTap: () {
        Provide.value<GoodsDetailProvide>(context).cutDetailComment(false);
      },
      child: Container(
        padding: EdgeInsets.all(10.0),
        alignment: Alignment.center,
        width: ScreenUtil().setWidth(375.0),
        decoration: BoxDecoration(
            color: Colors.white,
            border: Border(
                bottom: BorderSide(
                    width: 1.0, color: status ? Colors.white : Colors.pink))),
        child: Text(
          "评论",
          style: TextStyle(
              fontSize: ScreenUtil().setSp(28.0),
              color: status ? Colors.black : Colors.pink),
        ),
      ),
    );
  }
}
